Visualizing different types of data
Principles for making effective plots
Ideas are from “Fundamentals of Data Visualization” by Claus Wilke. You should check it out!
Slides are my own.
class: middle, center
Use bars
Use bars. Sensibly rearrange.
In this case: movie order and descending order.
Bars must go to zero: we interpret area. Don’t do this:
When zero doesn’t matter, use points:
x-labels too big? Don’t be afraid to swap axes.
Sorting, again.
Want to compare body mass of three penguin species? Please don’t use pinhead plots.
Plot all the data instead.
Even better, add some jitter and alpha transparency:
Too much data to show? Could use boxplots:
Could also make a histogram for each one.
Whatever you do, don’t combine and colour:
Better is to use density plots:
Even better is to use ridge plots:
Who care’s about the density values, anyway?
Can pack in many categories (ordered, of course).
You might even be able to get away with colouring by continent. (arguable)
Stacking just doesn’t work.
Putting bars beside each other is better, but still not good.
Best is to forego the bars and use lines:
Bonus: line up the legend.
Code and idea by Firas Moosvi
class: middle, center
How do you know there aren’t overlapping points here? You don’t.
Add some transparency, and suddenly you can tell.
Or, jitter the points a little bit.
When jittering isn’t an option, and alpha transparency isn’t enough?
Consider reducing the size of the points:
Or, use hexagonal binning (heatmap):
Don’t try to choose your own colours.
Avoid too many colours
Are you sure you just don’t want to highlight a few or even one category of interest?
Previous colour palette with Protanope (reduction of reds):
(Converted by hclwizard)
You could try to accommodate colour blindness and still use colour…
Viridis scale
Better yet, don’t rely on colour at all. Facet by species:
Notice the axes are comparable.
Here, the data are pressed against the y-axis. Tons of whitespace.
Use a log scale on the x-axis.
How can we make this plot better?
ggplot2 in R.ggplot2